<?php
/**
 * Created by PhpStorm.
 * User: ZNZG
 * Date: 2022/3/16
 * Time: 16:21
 */

namespace app\common\model;


class User extends BaseModel
{
    protected $pk = 'id';
    protected $autoWriteTimestamp = true;
    protected $createTime = 'created_at';
    protected $updateTime = 'updated_at';

    public function searchNameAttr($query, $value, $data)
    {
        $query->where('name', 'like', '%' . $value . '%');
    }

    public function searchPhoneAttr($query, $value, $data)
    {
        $query->where('phone', 'like', '%' . $value . '%');
    }

    public function searchCreatedAtAttr($query, $value, $data)
    {
        $query->whereBetweenTime('created_at', $value[0], $value[1]);
    }
}